package h0802;

import java.util.*;
import java.util.stream.Collectors;

/**
  * @description 字符统计与重排
  * @author 不知名帅哥
  * @date 2024/8/2 14:05
  * @version 1.0
*/
public class CharacterStatisticsAndRerangement {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s = sc.nextLine();
        Map<Character,Integer> statistics=new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            statistics.put(c,statistics.getOrDefault(c,0)+1);
        }
        List<Character> ans = statistics.keySet().stream().sorted(new Comparator<Character>() {
            @Override
            public int compare(Character o1, Character o2) {
                boolean b1 = Character.isLowerCase(o1);
                boolean b2 = Character.isLowerCase(o2);
                if (b1&&!b2){
                    return -1;
                }else if (!b1&&b2){
                    return 1;
                }else {

                }
                Integer a = statistics.get(o1);
                Integer b = statistics.get(o2);
                if (!a.equals(b)) {
                    return Integer.compare(a, b);
                } else {
                    return Character.compare(o1,o2);
                }
            }
        }).collect(Collectors.toList());

        StringBuilder sb=new StringBuilder();
        for (Character c : ans) {
            sb.append(c+":"+statistics.get(c)).append(";");
        }
        System.out.println(sb.toString());
    }
}
